package com.simon.mengkou.future.handler;

import android.content.Context;

import com.ouertech.android.agm.lib.base.future.core.event.ExceptionEvent;
import com.ouertech.android.agm.lib.base.future.local.LocalEvent;
import com.ouertech.android.agm.lib.base.utils.UtilLog;
import com.simon.mengkou.data.cache.DataCacheImpl;
import com.simon.mengkou.future.base.OuerLocalHandler;
import com.simon.mengkou.system.global.OuerApplication;

/**
 * Created by xiazhenshui on 16/6/24.
 */

public class SplashHandler extends OuerLocalHandler {

    public SplashHandler(Context context) {
        super(context);
    }

    @Override
    public void onHandle(LocalEvent evt) throws Exception {
        if(OuerApplication.mAppInfo.getVersionCode()
                != OuerApplication.mPreferences.getVersion()) {
            OuerApplication.mCacheFactory.clear();
            OuerApplication.mPreferences.setVersion(OuerApplication.mAppInfo.getVersionCode());
        }

        evt.getFuture().commitComplete(null);
    }

    @Override
    public void onException(ExceptionEvent evt) {
        evt.getFuture().commitException(null, evt.getException());
    }

    @Override
    public void onDispose() {

    }
}
